﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Nacos.V2;
using System.Threading.Tasks;
using System;

namespace NacosConfigDemo.Controllers
{

    [ApiController]
    [Route("[controller]")]
    public class ConfigController : ControllerBase
    {
        private readonly INacosConfigService _ns;


        public ConfigController(
             INacosConfigService ns
            )
        {
            _ns = ns;
        }

        [HttpGet]
        public async Task<string> Get()
        {
            var dataId = "common";
            var group = "DEFAULT_GROUP";

            var config = await _ns.GetConfig(dataId, group, 5000L);
            Console.WriteLine($"======================获取配置结果，{config}");

            return config;
        }

    }
}
